package com.hades.xq.factory.simple.carfactory;

import com.hades.xq.factory.simple.car.BenzCar;
import com.hades.xq.factory.simple.car.Car;
import com.hades.xq.factory.simple.car.LamborghiniCar;

public class CarFactory {

    public static Car getCar(String carName) {
        Car car = null;
        if ("A".equals(carName)) {
            car = new BenzCar();
        } else if ("L".equals(carName)) {
            car = new LamborghiniCar();
        } else {
            throw new IllegalArgumentException("没有此汽车。");
        }
        return car;
    }

}
